﻿using AiXiu.BLL;
using AiXiu.Common;
using AiXiu.IBLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AiXiu.WebSite
{
    /// <summary>
    /// DiscussPublishHandler 的摘要说明
    /// </summary>
    public class DiscussPublishHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            //接收参数
            string videoId = context.Request.QueryString["id"];
            string nickName = context.Request.Form["NickName"];
            string avatar = context.Request.Form["Avatar"];
            string content = context.Request.Form["Content"];
            string addTime = context.Request.Form["AddTime"];
            string replyTo= context.Request.Form["ReplayTo"];
            DateTime addTimeValue = TimeHelper.GetTimeByUnix(long.Parse(addTime));

            IDiscussManager discussManager = new DiscussManager();
            Model.Redis.Discuss discuss = new Model.Redis.Discuss() { 
                NickName=nickName,
                Avatar=avatar,
                Content=content,
                AddTime= addTimeValue,
                ReplayTo=replyTo
            };
            discussManager.Add(videoId, discuss);

            context.Response.ContentType = "text/plain";
            context.Response.Write("OK");
            context.Response.End();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}